package com.david.zhufengfm.tasks;

import com.david.zhufengfm.Constants;
import com.david.zhufengfm.client.ClientAPI;
import com.david.zhufengfm.utils.EntityParseUtil;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by David on 2015/10/23.
 * qq:978944820
 */
public class AlbumDetailTask extends BaseTask{

    public AlbumDetailTask(TaskCallback callback) {
        super(callback);
    }

    @Override
    protected TaskResult doInBackground(String... params) {
        TaskResult result=new TaskResult();
        String albumId=params[0];
        if (albumId != null) {

            result.action= Constants.TASK_ACTION_ALBUM_DETAIL;
            JSONObject jsonObject= ClientAPI.getAlbumDetail(Long.parseLong(albumId));
            if (jsonObject != null) {
                try {
                    result.resultCode=jsonObject.getInt("ret");
                    result.data= EntityParseUtil.parseAlbumDetail(jsonObject);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }

        return result;
    }

    @Override
    protected void onPostExecute(TaskResult result) {
        super.onPostExecute(result);
    }
}
